
const BASE_URL="https://tea.qingnian8.com/api/bizhi";

export function request(config={}){
	let {
		url,
		data={},
		method="GET",
		header={}
	} = config;
	header['access-key']="fcmldjt12138";
	return new Promise((resolve,reject)=>{
		uni.request({
			url:BASE_URL+url,
			data,
			method,
			header,
			success: (res) => {
				if(res.data.errCode===0){
					resolve(res);
					// console.log(res);
				}	
				else if(res.data.errCode===400){
					uni.showModal({
						title:"错误提示",
						content:res.data.errMsg,
						showCancel:false
					})
					reject(res);
				}else{
					uni.showToast({
						title: res.data.errMsg,
						icon:"none"
					});
					reject(res);
				}
			},
			fail: (res) => {
				reject(res);
			}
		})
	})
}
export async function apiGetBanner(){
	return await request({url:"/homeBanner"});
}
export async function apiGetRandomImg(){
	return await request({url:"/randomWall"});
}
export async function apiGetNotice(){
	return await request({url:"/wallNewsList"});
}
export async function apiGetClassifyImg(){
	return await request({url:"/classify"});
}
export async function apiGetWallpaperList(data){
	return await request({
		url:"/wallList",
		data:{
			"classid":data.classid,
			"pageSize":data.pageSize,
			"pageNum":data.pageNum
		}
		
	});
}
export async function apiSetScore(data){
	return await request({
		url:"/setupScore",
		data:{
			"classid":data.classid,
			"wallId":data.wallId,
			"userScore":data.userScore
		}
	});
}



